package com.ecmp.demo.controller;

import com.ecmp.annotation.IgnoreCheckAuth;
import com.ecmp.config.util.ApiClient;
import com.ecmp.core.controller.BaseEntityController;
import com.ecmp.demo.api.IStudentService;
import com.ecmp.demo.entity.Student;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

/**
 * Created by Administrator on 2017/8/10.
 */
@Controller
@IgnoreCheckAuth
@RequestMapping(value = "/student")
public class StudentController extends BaseEntityController<Student>{
     /**
        * 跳转到页面
     * @return  返回页面
     */
//    @RequestMapping(value = "show", method = RequestMethod.GET)
//    public String show() {
//        return "StudentView";
//    }


     @Override
     protected String getReturnView(HttpServletRequest request) {
         return "StudentView";
     }
     @Override
    protected Object getBaseService() {
        return ApiClient.createProxy(IStudentService.class);
    }
  /*  @ResponseBody
    @RequestMapping(value = "listAll")
    public List<Student> listAll() {
        IStudentService demoStudentService = ApiClient.createProxy(IStudentService .class);
        return demoStudentService.findAll();
    }*/

    /**
     * 根据id删除数据
     *
     * @param id
     * @return 操作结果
     * @throws JsonProcessingException
     */
/*    @RequestMapping(value = "delete")
    @ResponseBody
    public String delete(String id) throws JsonProcessingException {
        IStudentService proxy = ApiClient.createProxy(IStudentService .class);
        OperateResult result = proxy.delete(id);
        boolean success = result.successful();
        String msg = result.getMessage();
        OperateStatus operateStatus = new OperateStatus(success, msg);
        return JsonUtil.serialize(operateStatus);
    }*/

    /**
     * 保存主数据
     *
     * @param student
     * @return 操作结果
     * @throws JsonProcessingException
     */
 /*   @RequestMapping(value = "save")
    @ResponseBody
    public String save(Student student) throws JsonProcessingException {
        IStudentService proxy = ApiClient.createProxy(IStudentService.class);
        OperateResultWithData<Student> result = proxy.save(student);
        OperateStatus operateStatus = new OperateStatus(result.successful(), result.getMessage(), result.getData());
        return JsonUtil.serialize(operateStatus);
    }*/
}
